package com.ruoyi.web.controller.yijing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjBook;
import com.ruoyi.yijing.service.IYjBookService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 书本内容Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/book")
public class YjBookController extends BaseController
{
    @Autowired
    private IYjBookService yjBookService;

    /**
     * 查询书本内容列表
     */
    ////@PreAuthorize("@ss.hasPermi('yijing:book:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjBook yjBook)
    {
        startPage();
        List<YjBook> list = yjBookService.selectYjBookList(yjBook);
        return getDataTable(list);
    }


    /**
     * 获取书本内容详细信息
     */
    ////@PreAuthorize("@ss.hasPermi('yijing:book:query')")
    @GetMapping(value = "/{bookId}")
    public AjaxResult getInfo(@PathVariable("bookId") Integer bookId)
    {
        return success(yjBookService.selectYjBookByBookId(bookId));
    }

    /**
     * 新增书本内容
     */
    ////@PreAuthorize("@ss.hasPermi('yijing:book:add')")
    @Log(title = "书本内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjBook yjBook)
    {
        return toAjax(yjBookService.insertYjBook(yjBook));
    }

    /**
     * 修改书本内容
     */
    ////@PreAuthorize("@ss.hasPermi('yijing:book:edit')")
    @Log(title = "书本内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjBook yjBook)
    {
        return toAjax(yjBookService.updateYjBook(yjBook));
    }

    @Log(title = "书本内容", businessType = BusinessType.UPDATE)
    @PutMapping("updateStatus")
    public AjaxResult updateStatus(@RequestBody YjBook yjBook)
    {
        return toAjax(yjBookService.updateYjBook(yjBook));
    }


    /**
     * 删除书本内容
     */
    ////@PreAuthorize("@ss.hasPermi('yijing:book:remove')")
    @Log(title = "书本内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bookIds}")
    public AjaxResult remove(@PathVariable Integer[] bookIds)
    {
        return toAjax(yjBookService.deleteYjBookByBookIds(bookIds));
    }
}
